﻿
Imports System.Data.OracleClient
Imports ccapps.Web.page

Namespace persistent

    Public Class ChangeCustomerStatus

        Private Shared ConnStr As String = GlobalVar.OraConnStr

        Private Shared dbPackageName As String = "eu_bill.ChangeCustomerStatus."

        'procedure GetCustInfoFromCustcode (pin_custcode IN Varchar2, p_cursor OUT r_cursor_type);


        Public Shared Function GetCustInfoFromCustcode(ByVal pin_custcode As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustInfoFromCustcode")
            command.Parameters.Add("pin_custcode", OracleType.VarChar).Value = pin_custcode
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, pin_custcode, "", "null", "null", "Select(GetCustInfoFromCustcode)", "ChangeCustomerStatus", gen.Session("user"))
            Return ExecuteDataTable(command)

        End Function

        'procedure GetCustInfoFromMSISDN (pin_MSISDN IN Varchar2, p_cursor OUT r_cursor_type);  
        Public Shared Function GetCustInfoFromMSISDN(ByVal pin_MSISDN As String) As DataTable

            Dim command As New OracleCommand(dbPackageName & "GetCustInfoFromMSISDN")
            command.Parameters.Add("pin_MSISDN", OracleType.VarChar).Value = pin_MSISDN
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, "null", "", "null", pin_MSISDN, "Select(GetCustInfoFromMSISDN)", "ChangeCustomerStatus", gen.Session("user"))
            Return ExecuteDataTable(command)

        End Function
        'procedure DeactivationCustomer (pin_customer_id in integer,pin_ReasonCodeForStatusChange in integer,p_cursor OUT r_cursor_type)
        Public Shared Function DeactivationCustomer(ByVal pin_customer_id As Integer, ByVal pin_ReasonCodeForStatusChange As Integer) As DataTable

            Dim command As New OracleCommand(dbPackageName & "DeactivationCustomer")
            command.Parameters.Add("pin_customer_id", OracleType.Int32).Value = pin_customer_id
            command.Parameters.Add("pin_ReasonCodeForStatusChange", OracleType.Int32).Value = pin_ReasonCodeForStatusChange
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            'LOGLAMA
            Dim Query As String = "Select * from dual "
            Dim gen As Object = New GPOPrepaidToAveaPostpaidCustomerCreate()
            persistent.myDBConn.ORAScalar_LOG(Query, " null", pin_customer_id, "null", "null", "Select(DeactivationCustomer)", "ChangeCustomerStatus", gen.Session("user"))
            Return ExecuteDataTable(command)

        End Function

        Public Shared Function DeactivationReason() As DataTable

            Dim command As New OracleCommand(dbPackageName & "DeactivationReason")
            command.Parameters.Add("p_cursor", OracleType.Cursor).Direction = ParameterDirection.Output
            Return ExecuteDataTable(command)

        End Function



        Public Shared Function ExecuteNonQuery(ByVal command As OracleCommand, ByRef MESSAGE As String)
            Dim connection As New OracleConnection(ConnStr)
            command.Connection = connection
            command.CommandType = CommandType.StoredProcedure

            Try
                connection.Open()
                command.ExecuteNonQuery()
            Catch ex As Exception
                MESSAGE = ex.Message.ToString
            Finally
                connection.Close()
            End Try
        End Function
        Public Shared Function ExecuteDataTable(ByVal command As OracleCommand, Optional ByVal directSql As Boolean = 0) As DataTable
            Dim connection As New OracleConnection(ConnStr)
            Dim dataAdapter As New OracleDataAdapter(command)
            Dim dataTable As New DataTable
            Dim dataSet As New DataSet

            command.Connection = connection

            If Not (directSql) Then
                command.CommandType = CommandType.StoredProcedure
            End If

            Try
                connection.Open()
                dataAdapter.Fill(dataSet)
                dataTable = dataSet.Tables(0)
            Catch ex As Exception
            Finally
                connection.Close()
                dataSet.Dispose()
            End Try

            Return dataTable
        End Function




    End Class
End Namespace